package com.xcity.tools.skill;

import java.io.File;

import com.xcity.game.skill.template.SkillTemplate;

import naga.x.App;
import naga.x.common.Config;
import naga.x.game.template.TemplateParser;
import naga.x.game.template.TemplateService;
import naga.x.util.IOUtils;

/**
 * 战斗技能生成器
 * @author yang.li
 *
 */
public class CombatSkillGenerator {

	static final int[] SKILL_IDS = new int[] {
//			90113,
//			90114,
//			90115,
//			90116,
//			90117,
//			90118,
//			90119,
//			90120,
//			90121,
			90122,
//			90123,
//			90124,
//			90125,
//			90126,
//			90127,
//			90128,
//			90129,
//			90130,
	};
	static File baseDir = new File("F:/prj_java_svn/city-server/src/main/java/com/xcity/game/combat/skill/impl");
	
	public static void main(String[] args) throws Exception {
		App.getApp().setConfig(new Config());
//		App.getApp().getConfig().put(Config.DATA_DIR, "C:/Users/yang.li/Desktop/server_release/data");
		App.getApp().getConfig().dataDir = "C:/Users/yang.li/Desktop/server_release/data";
		
		TemplateService service = new TemplateService();
		TemplateParser parser = new TemplateParser(service);
		parser.parse(SkillTemplate.class);
		
		String codeTemplate = IOUtils.read(IOUtils.getResource("template_skill.txt"), IOUtils.UTF8);
//		String codeTemplate = IOUtils.read(new File("F:/prj_java/naga-x/city-tools/src/main/java/com/xcity/tools/template_skill.txt"), IOUtils.UTF8);
		for (int id : SKILL_IDS) {
			System.out.println(id);
			SkillTemplate template = service.get(SkillTemplate.class, id);
			String code = codeTemplate
					.replaceAll("#id#", String.valueOf(template.getId()))
					.replaceAll("#name#", template.getName())
					.replaceAll("#desc#", template.getDesc());
			System.out.println("=============================");
			File file = new File(baseDir, "COMBAT_SKILL_" + id + ".java");
			IOUtils.write(file, code, IOUtils.UTF8);
		}
		
	}
	
}
